﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Power.View.Dialog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;

namespace Power.ViewModel.Dialog
{
    public class AddWorkAreaViewModel : ViewModelBase
    {
        private AddWorkArea model;
        public AddWorkAreaViewModel(AddWorkArea model)
        {
            this.model = model;
            Close = new RelayCommand(OnClose);
            CloseOK = new RelayCommand(OnCloseOK);
            SelectFile = new RelayCommand(OnSelectFile);
        }

        //上传文件对话框
        private void OnSelectFile()
        {
            System.Windows.Forms.OpenFileDialog ofld = new System.Windows.Forms.OpenFileDialog();
            if (ofld.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string text = ofld.FileName;
                if (text != "" || text != null)
                {
                    this.model.FileAt.Text = text;
                }

            }
        }

        private void OnCloseOK()
        {
            //区域名称   文件路径  
            var workAreaName = this.model.WorkAreaName.Text;
            var filePath = this.model.FileAt.Text;
            this.model.DialogResult = true;
            this.model.Close();
            View.Dialog.ProgressBar box = new View.Dialog.ProgressBar();
            var result = box.ShowDialog();
        }

        private void OnClose()
        {
            this.model.DialogResult = false;
            this.model.Close();
        }

        #region 
        public RelayCommand Close { get; private set; }

        public RelayCommand CloseOK { get; private set; }

        public RelayCommand SelectFile { get; private set; }
        #endregion
    }
}
